package com.example.neteasecloudmusicapilearningproject.ktvSearch;
import android.view.LayoutInflater;
        import android.view.View;
        import android.view.ViewGroup;
        import android.widget.ImageView;
        import android.widget.TextView;
        import androidx.annotation.NonNull;
        import androidx.recyclerview.widget.RecyclerView;

import com.example.neteasecloudmusicapilearningproject.R;

import java.util.List;

public class KtvSearchAdapter extends RecyclerView.Adapter<KtvSearchAdapter.ViewHolder> {

    private List<KtvSearch> mktvSearchList;

    public KtvSearchAdapter (List<KtvSearch> ktvSearchList){
        mktvSearchList = ktvSearchList;
    }
    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.search_item_list,parent,false);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        KtvSearch ktvSearch = mktvSearchList.get(position);
        //holder.mktvSearchListImage.setImageResource(ktvSearch.getImageId());
        holder.mktvSearchListName.setText(ktvSearch.getName());
    }

    @Override
    public int getItemCount() {
        return mktvSearchList.size();
    }

    static class ViewHolder extends RecyclerView.ViewHolder {

       // ImageView mktvSearchListImage;
        TextView mktvSearchListName;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            //mktvSearchListImage = itemView.findViewById(R.id.showImage_start);
            mktvSearchListName = itemView.findViewById(R.id.tv_search_item_list);

        }
    }
}
